1. Field of the Invention
The preferred embodiments of the present invention are directed to run time management of heap memory. More particularly, the preferred embodiments of the present invention are directed to a concurrent non-blocking heap memory management method that allows software to remove and return blocks of memory from the heap simultaneously with a hardware agent returning blocks to the heap.
2. Background of the Invention
In the art of computer programming, a programmer may not know at the time of coding the amount of memory required to perform a particular operation. Rather than statically allocate memory large enough to encompass any situation that may arise, programmers may dynamically allocate memory at run time necessary to perform the desired operation, thus improving the utilization of computer resources.
Memory allocated for use at run time is typically referred to as heap memory. Heap memory is allocated for use by a particular process, which may include multiple threads. This use typically comprises the one or more software threads claiming or removing blocks of the heap memory, using the blocks of heap memory, and then returning the blocks to the unused heap pile for removal and use by other software threads.
An exemplary use of a removed block of heap memory is a buffer for the exchange of command lists and/or data from software threads to hardware devices. That is, a software thread may need to program or pass large amounts of data to a hardware device, and the size of the program or data block may be too large to pass by way of a direct communication message. In such an situation, the related art software threads claim or remove a portion of heap memory (which may include one of more blocks), place the command lists and/or data into the memory locations, and inform the hardware device of the location in main memory of the command lists and/or data locations. Once the hardware completes the necessary tasks or reads the data, the heap memory block or blocks remain removed from the unused heap pile.
In related art computer systems, the method by which blocks of heap memory are returned after a hardware device completes its tasks is by a software thread, either the invoking thread or another software thread, returning the block to the heap pile. More particularly, in related art computer systems, the hardware device invokes an interrupt to the microprocessor, which preempts executing software streams and loads and executes an interrupt service routine. The interrupt service routine identifies the reason for the interrupt, which is the notification that the hardware task has completed and the heap memory block or blocks are no longer needed, and either returns the heap memory block, or invokes other software streams to return the memory block. Thus, a software stream returns the block to the heap memory for further claiming or removal.
Returning heap memory using interrupts could be inefficient. This inefficiency is seen not only in the use of an interrupt from the hardware device to the microprocessor to pass the message that the heap memory block may be returned, but also in preempting other software streams to service the interrupt and return the block.
Thus, what is needed in the art is a way to return blocks of heap memory that does not require assistance of the central processing unit or software streams.